# koroFileHeader at Yungoal acer
# Create: 2022-02-07 11:25:54
# LastEdit: 2022-07-01 10:53:42
"""说明暂无"""
__author__ = '749B'


from django.urls import path
from django.db.models import Count

from . import views
from .models import Auth, Subscriptions


home_list_view = views.HomeListView.as_view(
    # queryset = Auth.objects.order_by("-name")[:5],  # :5 limits the results to the five most recent
    queryset = Auth.objects.filter(subscriptions__resources__del_time__isnull=True)
        .annotate(count=Count('subscriptions__resources')).order_by('-count'),
    context_object_name = "auth_list",
    template_name = "resource/home.html",
)

subscription_list_view = views.SubscriptionListView.as_view(
    queryset = Subscriptions.objects.filter(resources__del_time__isnull=True)
        .annotate(count=Count('resources')).order_by('auth', '-count'),
    context_object_name = "subscription_list",
    template_name = "resource/subscription.html",
)

app_name = 'resource'
urlpatterns = [
    path('', home_list_view, name='home'),
    path("subscriptions/", subscription_list_view, name="subscriptions"),
    path("resources/<str:auth>/<str:subscription>/<str:group_by>", views.resource_count, name="resources"),
    path("about/", views.about, name="about"),
    path("contact/", views.contact, name="contact"),
    path("logger/", views.log_console, name="logger"),
]
